package com.objetdirect.gwt.umldrawer.client;

import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Position;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.TextArea;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.layout.AnchorLayoutData;
import com.gwtext.client.widgets.layout.FitLayout;

public class MessageFormWindow extends Window {

	public void showMessageFormWindow() {

		this.setTitle("Send Message");
		this.setWidth(500);
		this.setHeight(300);
		this.setMinWidth(300);
		this.setMinHeight(200);
		this.setLayout(new FitLayout());
		this.setPaddings(5);
		this.setButtonAlign(Position.CENTER);

		Button sendButton = new Button("Send");
		this.addButton(sendButton);
		
		ButtonListenerAdapter sendButtonAdapter = new ButtonListenerAdapter() {
			@Override
			public void onClick(Button button, EventObject e) {
				MessageBox.alert("Server Info", "Your Message Has Been Sent!");
				hide();
			}
		};
		sendButton.addListener(sendButtonAdapter);
		
		Button cancelButton = new Button("Cancel");
		this.addButton(cancelButton);
		
		ButtonListenerAdapter cancelButtonAdapter = new ButtonListenerAdapter() {
			@Override
			public void onClick(Button button, EventObject e) {
				hide();
			}
		};
		cancelButton.addListener(cancelButtonAdapter);
		
		this.setCloseAction(Window.HIDE);
		this.setPlain(true);
		this.setModal(true);

		FormPanel formPanel = new FormPanel();
		formPanel.setBaseCls("x-plain");
		formPanel.setLabelWidth(55);
		formPanel.setUrl("save-form.php");

		formPanel.setWidth(500);
		formPanel.setHeight(300);

		formPanel.add(new TextField("Send To", "to"), new AnchorLayoutData(
				"100%"));

		formPanel.add(new TextField("Subject", "subject"),
				new AnchorLayoutData("100%"));

		TextArea textArea = new TextArea("Subject", "subject");
		textArea.setHideLabel(true);
		formPanel.add(textArea, new AnchorLayoutData("100% -53"));

		this.add(formPanel);
		this.show();
	}
}
